package com.whmskj.xjlhbc.mobile.controller;

import com.whmskj.xjlhbc.core.AjaxResult;
import com.whmskj.xjlhbc.core.Page;
import com.whmskj.xjlhbc.domain.DailyAttendanceLogMasterTable;
import com.whmskj.xjlhbc.domain.Sc13dWrotePlannerTable;
import com.whmskj.xjlhbc.dto.*;
import com.whmskj.xjlhbc.service.IKbService;
import com.whmskj.xjlhbc.service.ISb11dknittingstationstiedService;
import com.whmskj.xjlhbc.service.ISublistOfDailyAttendanceRecordsFService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/kb")
public class KbController {

    @Autowired
    private ISb11dknittingstationstiedService service;

    @Autowired
    private IKbService kbService;

    @Autowired
    private ISublistOfDailyAttendanceRecordsFService sublistOfDailyAttendanceRecordsFService;

    @GetMapping("/cl/realInfo")
    @Tag(name = "产量看板",description = "产量看板")
    @Operation(description = "实时班报-汇总")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ClKbDto.class})
    ))
    public AjaxResult realInfo(){
        ClKbDto result = kbService.clKbRealInfo();
        return AjaxResult.success(result);
    }

    @GetMapping("/cl/realInfoList")
    @Tag(name = "产量看板",description = "产量看板")
    @Operation(description = "实时班报-列表")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, Sc13dWrotePlannerTable.class})
    ))
    public AjaxResult realInfoList(){
        List<Sc13dWrotePlannerTable> list = service.zjktList(new ZjktQueryDto());
        return Page.getDataTable(list);
    }

    @GetMapping("/cl/day")
    @Tag(name = "产量看板",description = "产量看板")
    @Operation(description = "日产量",parameters = @Parameter(name = "date",description = "日期,yyyy-MM-dd"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ClKbListDto.class})
    ))
    public AjaxResult clKbDay(@RequestParam(required = false) String date){
        List<ClKbListDto> list = kbService.clKbDay(date);
        return AjaxResult.success(list);
    }

    @GetMapping("/cl/month")
    @Tag(name = "产量看板",description = "产量看板")
    @Operation(description = "月产量",parameters = @Parameter(name = "month",description = "月份,yyyy-MM"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ClKbListDto.class})
    ))
    public AjaxResult clKbMonth(@RequestParam(required = false) String month){
        List<ClKbListDto> list = kbService.clKbMonth(month);
        return AjaxResult.success(list);
    }

    @GetMapping("/wsd")
    @Tag(name = "温湿度看板",description = "温湿度看板")
    @Operation(description = "温湿度看板")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, WsdKbDto.class})
    ))
    public AjaxResult wsdKb(){
        WsdKbDto result = kbService.wsdKb();
        return AjaxResult.success(result);
    }

    @GetMapping("/kq/jrbb")
    @Tag(name = "考勤看板",description = "考勤看板")
    @Operation(description = "今日班报")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, DailyAttendanceLogMasterTable.class})
    ))
    public AjaxResult tjList(){
        QueryDto param = new QueryDto();
        param.setDateOfAttendance(LocalDate.now().toString());
        List<DailyAttendanceLogMasterTable> list = sublistOfDailyAttendanceRecordsFService.tjList(param);
        return AjaxResult.success(list);
    }

    @GetMapping("/kq/rtj")
    @Tag(name = "考勤看板",description = "考勤看板")
    @Operation(description = "日统计")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, DailyAttendanceLogMasterTable.class})
    ))
    public AjaxResult rtj(){
        List<DailyAttendanceLogMasterTable> list = kbService.kqKbRtj();
        return AjaxResult.success(list);
    }

    @GetMapping("/kq/ytj")
    @Tag(name = "考勤看板",description = "考勤看板")
    @Operation(description = "月统计")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, DailyAttendanceLogMasterTable.class})
    ))
    public AjaxResult ytj(){
        List<DailyAttendanceLogMasterTable> list = kbService.kqKbYtj();
        return AjaxResult.success(list);
    }


    @GetMapping("/jt")
    @Tag(name = "设备管理看板",description = "设备管理看板")
    @Operation(description = "设备管理看板")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, JtKbDto.class})
    ))
    public AjaxResult jt(){
        JtKbDto result = kbService.jtKb();
        return AjaxResult.success(result);
    }

    @GetMapping("/zzcj/rb")
    @Tag(name = "准整车间看板",description = "准整车间看板")
    @Operation(description = "日报表",parameters = @Parameter(name = "date",description = "日期,yyyy-MM-dd"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ZzcjKbDto.class})
    ))
    public AjaxResult zzcjRb(@RequestParam(required = false) String date){
        List<ZzcjKbDto> result = kbService.zzcjRb(date);
        return AjaxResult.success(result);
    }

    @GetMapping("/zzcj/yb")
    @Tag(name = "准整车间看板",description = "准整车间看板")
    @Operation(description = "月报表",parameters = @Parameter(name = "month",description = "月份,yyyy-MM"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ZzcjKbDto.class})
    ))
    public AjaxResult zzcjYb(@RequestParam(required = false) String month){
        List<ZzcjKbDto> result = kbService.zzcjYb(month);
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/realInfo")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "织布车间看板-汇总",parameters = @Parameter(name = "tab",description = "1:实时班产,2:状态分布,3:效率分布"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult zbcjRealInfo(@RequestParam(required = false,defaultValue = "1") int tab){
        List<String> result = kbService.zbcjRealInfo(tab);
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/bzdb")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "班组对比",parameters = @Parameter(name = "date",description = "日期,yyyy-MM-dd"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult zbcjbzdb(@RequestParam(required = false) String date){
        List<Map<String,String>> result = kbService.zbcjBzdb(date);
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/rb")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "日报表",parameters = @Parameter(name = "date",description = "日期,yyyy-MM-dd"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ZbcjKbDto.class})
    ))
    public AjaxResult zbcjRb(@RequestParam(required = false) String date){
        List<ZbcjKbDto> result = kbService.zbcjRb(date);
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/yb")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "月报表",parameters = @Parameter(name = "month",description = "月份,yyyy-MM"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class, ZbcjKbDto.class})
    ))
    public AjaxResult zbcjYb(@RequestParam(required = false) String month){
        List<ZbcjKbDto> result = kbService.zbcjYb(month);
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/jttj")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "机台停机统计",parameters = @Parameter(name = "date",description = "日期,yyyy-MM-dd"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult zbcjJttj(@RequestParam(required = false) String date){
        List<Map<String,String>> result = kbService.zbcjJttj(date);
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/xlph")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "机台效率排行")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult zbcjXlph(){
        List<Map<String,Object>> result = kbService.zbcjXlph();
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/tjsc")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "停机时长排行")
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult zbcjTjsc(){
        List<Map<String,String>> result = kbService.zbcjTjsc();
        return AjaxResult.success(result);
    }

    @GetMapping("/zbcj/tj")
    @Tag(name = "织布车间看板",description = "织布车间看板")
    @Operation(description = "机台停机统计",parameters = @Parameter(name = "date",description = "日期,yyyy-MM-dd"))
    @ApiResponse(content = @Content(
            schema = @Schema(anyOf = {AjaxResult.class})
    ))
    public AjaxResult zbcjTj(@RequestParam(required = false) String date){
        List<Map<String,String>> result = kbService.zbcjTj(date);
        return Page.getDataTable(result);
    }


}
